package cn.zn.modules.pz.enums;

import cn.hutool.core.collection.CollUtil;
import cn.zn.framework.common.vo.ComboxItemVO;
import lombok.Getter;

import java.util.List;

@Getter
public enum ExpenseWayEnum {
    /**
     *
     */
    EW_001("001", "现金"),
    EW_002("002", "公务卡"),
    EW_003("003", "对公转账"),
    EW_004("004", "个人转账"),
//    EW_005("005", "其他"),
    ;

    private String code;
    private String name;

    ExpenseWayEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static ExpenseWayEnum findByCode(String code) {
        for (ExpenseWayEnum e : values()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        return null;
    }
    public static List<ComboxItemVO> buildCombox() {
        List<ComboxItemVO> list = CollUtil.newArrayList();
        ExpenseWayEnum expenseWayEnum;
        for (int i = 0; i < values().length; i++) {
            expenseWayEnum = values()[i];
            list.add(ComboxItemVO.builder()
                    .value(expenseWayEnum.code)
                    .text(expenseWayEnum.name)
                    .build());
        }
        return list;
    }

}
